# Maintainer: Daniel Espinosa <esodan@gmail.com>

_realname=librescl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.3.3
pkgrel=1
arch=('any')
pkgdesc="Reader/Writer SCL IEC 61850-6 files (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-gettext"
         "${MINGW_PACKAGE_PREFIX}-glib2>=2.34.0"
         "${MINGW_PACKAGE_PREFIX}-gobject-introspection"
         "${MINGW_PACKAGE_PREFIX}-gxml"
         "${MINGW_PACKAGE_PREFIX}-libgee"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-vala"
         "${MINGW_PACKAGE_PREFIX}-xz"
         "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config" "${MINGW_PACKAGE_PREFIX}-libtool")
options=('strip' 'staticlibs')
license=('LGPL')
url="https://github.com/pwmediaconsulting/librescl"
source=("https://github.com/pwmediaconsulting/librescl/archive/LIBRESCL_${pkgver//./_}.tar.gz")
sha256sums=('9b1ffec7a11cd92e36bfb590b3a9b99d0bf39d2895a5e4c76c65998a19fb57c5')

prepare() {
  cd "${srcdir}"/librescl-LIBRESCL_${pkgver//./_}

  NOCONFIGURE=1 ./autogen.sh
  #make distclean
  #autoreconf -fiv
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../librescl-LIBRESCL_${pkgver//./_}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}
